from gxl_ai_utils.utils import utils_file

# input_data_list_path = "/teaspeech_ceph/share_976139/users/xuelonggeng/data/emotion_data/ft_local/raw_data/data.list"
# output_dir = "/teaspeech_ceph/share_976139/users/xuelonggeng/data/emotion_data/ft_local/raw_data"
# utils_file.do_convert_jsonl_to_wav_text_scp(input_data_list_path, f'{output_dir}/wav.scp', f'{output_dir}/text.scp')
def get_int_from_str(score_str):
    """"""
    try:
        score_float = float(score_str)
        score_int = int(round(score_float))
        return score_int
    except ValueError:
        print(f"无法将 '{score_str}' 转换为整数。")
        return -1
wav_path = "/teaspeech_ceph/share_976139/users/xuelonggeng/data/emotion_data/ft_local/raw_data/wav.scp"
# score_path = "/teaspeech_ceph/share_976139/users/xuelonggeng/data/emotion_data/ft_local/score_int.scp"
score_path = "/apdcephfs_qy3/share_976139/users/xuelonggeng/data/emotion_data/ft_local/score_int.scp"
score_dict = utils_file.load_dict_from_scp(score_path)
low_int = 5
new_score_dict = {k: v for k, v in score_dict.items() if get_int_from_str(v) < low_int}
wav_dict = utils_file.load_dict_from_scp(wav_path)
new_wav_dict = {k: v for k, v in wav_dict.items() if k in new_score_dict}
output_wav_path = "/teaspeech_ceph/share_976139/users/xuelonggeng/data/emotion_data/ft_local/raw_data/wav_score_low_5.scp"
utils_file.write_dict_to_scp(new_wav_dict, output_wav_path)